import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  optimizeDeps: {
    // 开发时 解决这些commonjs包转成esm包
    include: [
      "@jiaminghi/c-render",
      "@jiaminghi/c-render/lib/plugin/util",
      "@jiaminghi/charts/lib/util/index",
      "@jiaminghi/charts/lib/util",
      "@jiaminghi/charts/lib/extend/index",
      "@jiaminghi/charts",
      "@jiaminghi/color",
    ],
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server:{
    port:9290,
    host: "124.167.249.190",
    proxy: {
      "^/api": {
        // target: "http://192.168.1.102:9099",
        // target: "http://172.16.1.45:9099",
        target: "http://124.167.249.190:9099", //124.167.249.190    124.167.20.235怀仁
        changeOrigin: true, // 允许跨域
        secure: false, //要想在没有证书的情况下，依然能成功代理到目标是 HTTPS 协议的服务器上
        // rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  }
})
